package com.twu.biblioteca.model;

import com.twu.biblioteca.controller.User;

import java.util.ArrayList;

/**
 * Created by ggoulart on 9/29/14.
 */
public class UserDAO {

    private ArrayList<User> users = new ArrayList<User>();

    public UserDAO() {
        users.add(new User("123-4567", "123456", "Gustavo", "gustavo@goulart.com", "1234-5678"));
    }

    public User findUserByLibraryNumber(String libraryNumber) throws Exception {
        for(User user : users) {
            if(user.getLibraryNumber().equals(libraryNumber))
                return user;
        }
        throw new Exception("Library number doesn't exists.");
    }

    public boolean addUser(User user) {
        return users.add(user);
    }
}
